// 导入 mongoose 模块
const mongo = require("mongoose");

// 连接 mongodb 服务
mongo.connect("mongodb://127.0.0.1:27017/bilibili");

// 设置回调
mongo.connection.once("open", () => {
  console.log("连接成功");
});

mongo.connection.on("error", () => {
  console.log("连接失败");
});

mongo.connection.on("close", () => {
  console.log("连接关闭");
});

// 关闭 mongodb 连接
setTimeout(() => {
  mongo.disconnect();
}, 2000);
